package com.estate.parking.controller;


import com.estate.bean.Parking;
import com.estate.bean.ParkingUse;
import com.estate.parking.service.ParkingUseService;
import com.estate.util.JsonResult;
import com.estate.util.ResultTool;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/parking/use")
@Slf4j
public class ParkingUseController {

    @Resource
    private ParkingUseService parkingUseService;

    @GetMapping("list/{page}/{size}")
    public JsonResult list(@PathVariable("page") int page, @PathVariable("size") int size) {
        log.info("page:{},size:{}", page, size);
        JsonResult result = parkingUseService.listByPage(page, size);
        log.info("result:{}", result);
        return result;
    }

    @PostMapping("/save")
    public JsonResult save(ParkingUse parkingUse) {
        log.info("新增parkingUse:{}", parkingUse);
        JsonResult result = parkingUseService.savePackingUse(parkingUse);
        log.info("result:{}", result);
        return result;
    }

    @PutMapping("/update")
    public JsonResult update(ParkingUse parkingUse) {
        log.info("修改parkingUse:{}", parkingUse);
        JsonResult result = parkingUseService.updateParkingUse(parkingUse);
        log.info("result:{}", result);
        return result;
    }

    @DeleteMapping("/delete")
    public JsonResult delete(@RequestParam("parkingUseId") String parkingUseId) {
        log.info("删除parkingUse:{}", parkingUseId);
        JsonResult result = parkingUseService.deleteParkingUse(parkingUseId);
        log.info("result:{}", result);
        return result;
    }

    @GetMapping("/list/{parkingUseId}")
    public JsonResult list(@PathVariable("parkingUseId") String parkingUseId) {
        log.info("parkingUseId:{}", parkingUseId);
        JsonResult result = ResultTool.success(parkingUseService.getById(parkingUseId));
        log.info("result:{}", result);
        return result;
    }
}
